package com.xz.spi.proxy;

import com.xz.simplerpc.api.HelloService;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * Created by fingal on 2018/1/7.
 */
public class HelloServiceDynamicProxy implements InvocationHandler {

    private HelloService target;
    public HelloServiceDynamicProxy(HelloService target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("before say hello...");

        Object result = method.invoke(target, args);

        System.out.println("after say hello...");

        return result;
    }
}
